package com.jasonchoi.gateway;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.core.Ordered;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * 自定义路由过滤器
 * @Author: JasonChoi
 * @Date: 2019/12/18 14:48
 */
public class MyCustomGatewayFilter implements GatewayFilter, Ordered {
    private static final Log log = LogFactory.getLog(MyCustomGatewayFilter.class);
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        log.info("MyCustomGateWayFilter --> " + exchange.getRequest().getURI().getRawPath());
        return chain.filter(exchange).then();
    }

    @Override
    public int getOrder() {
        return 3;
    }
}
